#!/bin/bash

PROGNAME="${BASH_SOURCE[0]}"
HERE="$(cd "$(dirname "$PROGNAME")" &>/dev/null && pwd)"
READIES=$(cd $HERE/.. && pwd)
. $READIES/shibumi/defs

echo "Extacting debug symbols from $1 ..."

if [[ -z $1 || ! -f $1 ]]; then
	eprint "$1 not found"
	exit 1
fi

cp "$1" "$1.debug"
objcopy --add-gnu-debuglink "$1.debug" "$1"
strip -g "$1"

# rm -f "$1.debug"
# objcopy --only-keep-debug "$1" "$1.debug"
# objcopy --strip-debug "$1"
# objcopy --add-gnu-debuglink "$1.debug" "$1"
